home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Generic_Sentry.abl < prev    next >
Encoding:
Text File  |  2001-07-16  |  4.4 KB  |  152 lines

  1.  
  2. //------------------------------------------------------------------
  3. // NOTE: The fsm name below MUST be changed in order for the
  4. // script to be considered a unique entity!
  5.  
  6. fsm Generic_Sentry : integer;
  7.  
  8.  
  9. //------------------------------------------------------------------
  10.  
  11. // Generic_Sentry:
  12. //   Stands still.  Moves to attack anything that comes near.
  13. //
  14. //------------------------------------------------------------------
  15.  
  16.  
  17.  
  18. //------------------------------------------------------------------
  19. //     Constants
  20. //------------------------------------------------------------------
  21.  
  22.     const
  23.         #include_ <content\ABLScripts\mwconst.abi>
  24.  
  25. //------------------------------------------------------------------
  26. //     Types
  27. //------------------------------------------------------------------
  28.  
  29.     type
  30.         #include_ <content\ABLScripts\mwtype.abi>
  31.     
  32.  
  33. //------------------------------------------------------------------
  34. //     Variables
  35. //------------------------------------------------------------------
  36.  
  37.     var
  38.         static integer            attackRange;        // At what range do I start shooting?
  39.         static integer            withdrawRange;        // At what range do I withdraw from combat completely?
  40.  
  41.         static integer            piloting;            // Piloting skill
  42.         static integer            gunnery;            // Gunnery skill/chance to hit
  43.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  44.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  45.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  46.                                                     // and other things.  It indicates a general level of combat experience.
  47.         static integer            attackThrottle;        // My attack throttle
  48.         static integer            findTypes;            // What kind of enemies to look for
  49.  
  50.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  51.  
  52.         static integer             attackSound;        // The attack sound I play when I first attack
  53.         static integer             deathSound;            // The sound I play when I die
  54.         
  55.         static integer            mood;                // My default mood.
  56.  
  57.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  58.  
  59. //------------------------------------------------------------------
  60. //     Init: my initialization function
  61. //------------------------------------------------------------------
  62.  
  63. function Init;
  64.     code
  65.         // script-specific variables
  66.         attackRange        = 500;
  67.         withdrawRange    = attackRange * 3 / 2;
  68.         takeOffDistance    = 150;
  69.  
  70.         // driver settings
  71.         piloting        = 50;
  72.         gunnery            = 30;
  73.         minDelay        = 1.5;
  74.         maxDelay        = 3.0;
  75.         eliteLevel        = 30;
  76.         attackThrottle    = 80;
  77.         isShotRadius    = 120;
  78.         attackSound        = -1; // no sound
  79.         deathSound        = -1; // no sound
  80.         mood            = NEUTRAL_START;
  81.         findTypes        = FT_DEFAULT;
  82.  
  83. endfunction;
  84.  
  85. //------------------------------------------------------------------
  86. //    StartState: my initial state
  87. //------------------------------------------------------------------
  88.  
  89. state StartState;
  90.  
  91.     code
  92.         SetFiringDelay            (ME,minDelay,maxDelay);
  93.         SetIgnoreFriendlyFire    (ME,true);
  94.         SetIsShotRadius            (ME,isShotRadius);
  95.         SetEntropyMood            (ME,mood);
  96.         SetCurMood                (ME,mood);
  97.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  98.         SetAttackThrottle        (ME,attackThrottle);
  99.                 
  100.         if (orderTakeOff(takeOffDistance) == true) then
  101.             trans WaitState;
  102.         endif;
  103.  
  104. endstate;
  105.  
  106. //------------------------------------------------------------------
  107. //    WaitState: wait for something to shoot
  108. //------------------------------------------------------------------
  109.  
  110. state WaitState;
  111.     code
  112.         OrderMoveLookOut;
  113.  
  114.         if (FindEnemy(attackRange,findTypes)) then
  115.             trans AttackState;
  116.         endif;        
  117. endstate;
  118.  
  119. //------------------------------------------------------------------
  120. //    AttackState: look for something to shoot
  121. //------------------------------------------------------------------
  122.  
  123. state AttackState;
  124.     code
  125.         if (LeaveAttackState(withdrawRange)) then
  126.             OrderStopAttacking;
  127.             SetTarget(ME,NO_UNIT);
  128.             trans WaitState;
  129.         endif;
  130.  
  131.         OrderAttack(true);
  132.  
  133. endstate;
  134.  
  135. //------------------------------------------------------------------
  136. //    DeadState: OK, I kicked the bucket.
  137. //------------------------------------------------------------------
  138.  
  139. state DeadState;
  140.     code
  141.         if (deathSound <> -1) then    
  142.             PlaySoundOnce(deathSound);
  143.         endif;        
  144.  
  145.         orderDie;
  146.  
  147. endstate;
  148.  
  149.  
  150. endfsm.
  151.  
  152.